<?php
class EditComment extends Action {
	/*
	 * (non-PHPdoc) @see Action::execute()
	 */
	public function execute($params) {
		check_login ( ADMIN_LOGIN_PAGE );
		
		$data = array ();		
		$cid = irqst ( 'cid' );
		$cmM = new WebCommentModel ();
		if (empty ( $cid )) {
			$data ['page_tip_info'] = "<strong>出错啦!</strong>comment_id为空，系统无法加载对应评论。";
			Response::redirect ( $this->referer );
		} else {
			$comment = sess_del ( 'comment_form_data', false );
			if (! $comment) {
				$comment = $cmM->read ( $cid );
			}
			if ($comment == false) {
				$data ['page_tip_info'] = "<strong>出错啦!</strong>comment_id为{$cid}的评论不存在。";
				Response::redirect ( $this->referer );
			} else {
				$data = $comment;
				$data ['page_tip_info'] = sess_del ( 'page_tip_info' );
			}
		}
		$data ['navi_active'] = '<i class="icon-edit"></i>编辑评论';
		$data ['refer_url'] = sess_get ( 'comment_list_url' );
		return new SmartyView ( $data, 'comment/CommentForm' );
	}
}